#include <stdio.h>

int Is_Leap_Year(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return 1;
	}
	return 0;
}

int main()
{
	int year = 0;
	int month = 0;
	scanf("%d%d", &year, &month);
	int day[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int ret = Is_Leap_Year(year);
	if (ret)
	{
		day[2] = 29;
	}
	printf("%d\n", day[month]);

	return 0;
}